
/**
 * @Description: 三维球体 操作 函数集合
 * @Author: Darren_yan
 * @Date: 2025-06-27 15:29:02
 * @LastEditors: Darren_yan
 * @LastEditTime: 2025-06-27 15:29:02
 */
import { isExist } from '../tools/index.js'
/**
 *@Description:  加载dem地形 数据
 */
function addGlobeTerrainProvider({url,headerLists,requestWaterMask,requestVertexNormals,name }){
	if(!window.viewer) return

	if (!isExist(url)) {
		console.error('url 错误')
		return
	}

	let terrainProvider = new SSmap.GlobeTerrainProvider(url);

	if (isExist(headerLists) && (typeof headerLists) === "object") {
		headerLists.forEach(item => {
			terrainProvider.setHeader(item.key, item.value)
		});		
	}
	if (isExist(requestWaterMask)) terrainProvider.requestWaterMask = requestWaterMask //请求水面
	if (isExist(requestVertexNormals)) terrainProvider.requestVertexNormals = requestVertexNormals //请求顶点向量
	if (isExist(name)) terrainProvider.objectName = name //命名	 
	window.viewer.scene.globe.terrainProvider = terrainProvider;
}

/* 
 *@Description: 移除 dem地形 数据
*/
function removeGlobeTerrainProvider(){
	window.viewer.scene.globe.setDefaultTerrain()
}

export {addGlobeTerrainProvider,removeGlobeTerrainProvider}